#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char* licenseKeyFormatting(char* s, int k)
{
    int n = strlen(s);
    int count = 0;

    for (int i = 0; i < n; i++) {
        if (s[i] == '-') {
            count += 1;
        }
    }

    char* res = (char*)malloc(sizeof(char) * (n + n / k + 2 - count));

    int tmp = (n - count) % k;
    int index = 0;

    int cur = 0;
    for (int j = 0; j < n; j++) {
        char ch = s[j];
        if (s[j] == '-') {
            continue;
        }
        else if (ch >= 'a' && ch <= 'z') {  
            ch = ch - 'a' + 'A';
        }

        if (tmp != 0 && (index == tmp || (cur - tmp) % k == 0)) {
            res[index] = '-';
            index += 1;
        }

        res[index] = ch;
        index += 1;
        cur += 1;
    }
    res[index] = '\0';
    return res;
}


int main()
{
	return 0;
}